package com.tiger.admin.http.deptContacts;

import com.tiger.admin.SaveOperateLog;
import com.tiger.utils.ResponseUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;
import java.util.List;

@RestController
@RequestMapping("deptContacts")
public class DeptContactsController {
    private final DeptContactsService deptContactsService;

    public DeptContactsController(DeptContactsService deptContactsService) {
        this.deptContactsService = deptContactsService;
    }

    @GetMapping("list")
    public Object list() {
        return ResponseUtil.successRes(deptContactsService.list());
    }

    /**
     * **/
    //@SaveOperateLog("导入服务")
//    @PostMapping("import")
//    public Object importApps(@RequestParam("file") MultipartFile file) {
//        deptContactsService.importContacts(file);
//
//        return ResponseUtil.successRes();
//    }

    @PostMapping("import")
    public Object importApps(@RequestBody() List<HashMap<String, Object>> data) {
        deptContactsService.importContacts(data);

        return ResponseUtil.successRes();
    }

    @PostMapping("delete")
    public Object del(@RequestBody() HashMap<String, Integer> data) {
        deptContactsService.delContacts(data.get("id"), data.get("index"), data.get("i"));
        return ResponseUtil.successRes();
    }
}
